package q1662_arrayStringsAreEqual;

public class Solution_2 {
    /*
    双指针 + 双指针
     */
    public boolean arrayStringsAreEqual(String[] word1, String[] word2) {
        int idx1 = 0, idx2 = 0, p1 = 0, p2 = 0;
        for (; idx1 < word1.length && idx2 < word2.length; ) {
            if (word1[idx1].charAt(p1) != word2[idx2].charAt(p2)) return false;
            ++p1;
            if (p1 == word1[idx1].length()) {
                ++idx1;
                p1 = 0;
            }
            ++p2;
            if (p2 == word2[idx2].length()) {
                ++idx2;
                p2 = 0;
            }
        }
        return idx1 == word1.length && idx2 == word2.length;
    }
}
